package com.xdcplus.web.controller.wip;



import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.wip.WipWetWeightAlarmRecordDTO;
import com.xdcplus.web.common.pojo.dto.wip.WipWetWeightAlarmRecordFilterDTO;
import com.xdcplus.web.common.pojo.vo.wip.WipWetWeightAlarmRecordVO;
import com.xdcplus.web.service.wip.WipWetWeightAlarmRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * (WipWetWeightAlarmRecord)表服务控制层
 *
 * @author Zhecheng.Ren
 * @since 2024-10-22 15:14:13
 */
@Api(tags = "(WipWetWeightAlarmRecord)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("wipWetWeightAlarmRecord")
public class WipWetWeightAlarmRecordController extends AbstractController {

    @Resource
    private WipWetWeightAlarmRecordService wipWetWeightAlarmRecordService;

    @ApiOperation("新增")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<Void> saveWipWetWeightAlarmRecord(@RequestBody WipWetWeightAlarmRecordDTO wipWetWeightAlarmRecordDTO) {

        log.info("saveWipWetWeightAlarmRecord {}", wipWetWeightAlarmRecordDTO.toString());

        wipWetWeightAlarmRecordDTO.setCreatedUser(getAccount());
        wipWetWeightAlarmRecordService.saveWipWetWeightAlarmRecord(wipWetWeightAlarmRecordDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<Void> updateWipWetWeightAlarmRecord(@RequestBody WipWetWeightAlarmRecordDTO wipWetWeightAlarmRecordDTO) {

        log.info("updateWipWetWeightAlarmRecord {}", wipWetWeightAlarmRecordDTO.toString());

        wipWetWeightAlarmRecordDTO.setUpdatedUser(getAccount());
        wipWetWeightAlarmRecordService.updateWipWetWeightAlarmRecord(wipWetWeightAlarmRecordDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除")
    @DeleteMapping(value = "/{wipWetWeightAlarmRecordId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "wipWetWeightAlarmRecordId", dataTypeClass = Long.class, value = "ID", required = true),
    })
    public ResponseVO<Void> deleteWipWetWeightAlarmRecordLogical(@PathVariable("wipWetWeightAlarmRecordId")
                                         @NotNull(message = "ID不能为空") Long wipWetWeightAlarmRecordId) {

        log.info("deleteWipWetWeightAlarmRecordLogical {}", wipWetWeightAlarmRecordId);

        wipWetWeightAlarmRecordService.deleteWipWetWeightAlarmRecordLogical(wipWetWeightAlarmRecordId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除")
    @DeleteMapping(value = "/deleteByIds/{wipWetWeightAlarmRecordIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "wipWetWeightAlarmRecordId", dataTypeClass = Long.class, value = "ID", required = true),
    })
    public ResponseVO<Void> deleteWipWetWeightAlarmRecordLogical(@PathVariable("wipWetWeightAlarmRecordIds")
                                         @NotNull(message = "ID不能为空") String wipWetWeightAlarmRecordIds) {

        log.info("deleteWipWetWeightAlarmRecordByIds {}", wipWetWeightAlarmRecordIds);

        wipWetWeightAlarmRecordService.deleteWipWetWeightAlarmRecordByIds(wipWetWeightAlarmRecordIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<WipWetWeightAlarmRecordVO>> findWipWetWeightAlarmRecord(WipWetWeightAlarmRecordFilterDTO wipWetWeightAlarmRecordFilterDTO) {

        log.info("findWipWetWeightAlarmRecord {}", wipWetWeightAlarmRecordFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(wipWetWeightAlarmRecordFilterDTO);

        return ResponseVO.success(wipWetWeightAlarmRecordService.queryWipWetWeightAlarmRecord(wipWetWeightAlarmRecordFilterDTO));
    }


}
